package io.jjz.consts;

public enum OrderField {
    yearTradeAmount("1", "YTA"),
    yearTradeNum("2", "YTN"),
    totalMchNum("3", "TMN"),
    dailyTradeAmount("4", "DTA"),
    dailyAmountPercent("5", "DAP"),
    dailyTradeNum("6", "DTN"),
    dailyNumPercent("7", "DNP"),
    monthTradeAmount("8", "MTA"),
    monthTradeNum("9", "MTN"),
    month2AmountPercent("10", "M2AP"),
    month2NumPercent("11", "M2NP"),
    monthAmountPercent("12", "MAP"),
    monthNumPercent("13", "MNP");

    private String id;
    private String name;

    OrderField(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static boolean isValid(String value) {
        if (value == null) {
            return false;
        }
        OrderField[] values = OrderField.values();
        for (OrderField e : values) {
            if (e.name.equals(value)) {
                return true;
            }
        }
        return false;
    }

    public static String getNameById(String id) {
        OrderField[] values = OrderField.values();
        for (OrderField e : values) {
            if (e.id.equals(id)) {
                return e.name;
            }
        }
        return "";
    }

}
